<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
		<meta charset="utf-8" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />

</head>
<body>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">学校组织结构</a></li>
    <li><a href="#">班级信息</a></li>
    </ul>
    </div>
    <div class="rightinfo">
    <div class="tools">
    <form id="searchForm" class="form-search" action="classInfo/classInfo_page_list.do" method="post">
    	<ul class="seachform1">
    	<c:if test="${userRole <=2 }">
    		<li>选择院系：</li>
    	    <li>
    	    <select id="dpselect" name="SSXSXYDM" class="chosen-select col-xs-10 col-sm-5" onchange="selectChanged();">
						<option value="" > -- 全部 -- </option>
						<c:forEach items="${departmentInfoList}" var="departmentInfo">
							<option value="${departmentInfo.XYDM }" <c:if test="${departmentInfo.XYDM == SSXSXYDM }">selected</c:if> >${departmentInfo.XYMC }</option>
						</c:forEach>
					</select>
    	</li>
    	</c:if>
    	<c:if test="${userRole >2 }">
    	<li><input value="${departmentName }" name="SSXSXYDM" type="hidden">${departmentName } </li>
    	</c:if>
		<li>选择专业：</li>  
    	<li>
    		<select name="SSZYDM" id="SSZYDM" class="chosen-select col-xs-10 col-sm-5" >
						<option value="" > -- 全部 -- </option>
						<c:forEach items="${professionInfoList}" var="professionInfo">
							<option value="${professionInfo.ZYDM }" <c:if test="${professionInfo.ZYDM == SSZYDM }">selected</c:if> >${professionInfo.ZYMC }</option>
						</c:forEach>
					</select>
    	</li>
		<li><input name="" type="button" class="scbtn" id="btnSearch" value="查询"/></li>  
		<input type="hidden" name="pageNumber" value="1" /> 
		</ul>	
		</form>
    	<!--<ul class="toolbar">
        <li class="click"><span><img src="images/t01.png" /></span>添加</li>
        <li class="click"><span><img src="images/t02.png" /></span>修改</li>
        <li><span><img src="images/t03.png" /></span>删除</li>
        <li><span><img src="images/t04.png" /></span>统计</li>
        </ul>
        <ul class="toolbar1">
        <li><span><img src="images/t05.png" /></span>设置</li>
        </ul>
    -->
    </div>
    <table class="tablelist">
    	<thead>
    	<tr>
         <th>班级代码</th>
        <th>班级名称</th>
        <th>年级</th>
        <th>所属专业</th>
        <th>所属院系</th>
        <th>班级辅导员</th>
      </tr>
        </thead>
        <tbody>
          <c:forEach items="${classInfoList}" var="classInfo"  varStatus="status">
      <tr>
       <td>${classInfo.BJDM }</td>
       <td>${classInfo.BJMC }</td>
       <td>${classInfo.NJ }</td>
       <td>${classInfo.XYMC }</td>
       <td>${classInfo.ZYMC }</td>
       <td>${classInfo.XM }</td>
      </tr> 
      </c:forEach>
        </tbody>
    </table>
    <div class="pagin">
    	<%@ include file="page.jsp"%>
    </div>
    </div>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	$( "#btnSearch" ).on('click', function(e) {
		$("#searchForm").submit();
	});
	function GoToPage(toPage,totalPage) {
	    if(toPage<=0) return;
	    if(toPage>totalPage) return;
	    $("input[name='pageNumber']").val(toPage);
	    $("#searchForm").submit();
	};
	function selectChanged() {
		 var ele=document.getElementById('dpselect');
   	  	var index=ele.selectedIndex;
   	 	 var val=ele.options[index].value;
   	 	$.ajax({
			type: "POST",
			url: "classInfo/departmentInfo.do",
			data: { SSXSXYDM : val},
			async: true,
			dataType: "json",
			success: function(data) {
				$("#SSZYDM").empty();
				var all="<option value='' >-- 全部 -- </option>";
				for(var i in data.professionInfoList){  
					var $str = "<option value="+data.professionInfoList[i].ZYDM +">"+data.professionInfoList[i].ZYMC +"</option>";
					$("#SSZYDM").append($str);  	 
				}
				$("#SSZYDM").append(all);
			}
			})
	}

	
	</script>
</body>
</html>
